package cn.beforedark.y24.m09.d21.p1;

import java.util.Iterator;
import java.util.concurrent.CopyOnWriteArrayList;

public class Main {
    public static void main(String[] args) {
        CopyOnWriteArrayList<String> arr = new CopyOnWriteArrayList<>();
        for (int i = 0; i < 1000; i++) {
            arr.add("默认值");
        }
        Iterator<String> iterator = arr.iterator();

        Runnable r1 = () -> {
            for (int i = 999; i > -1; i--) {
                arr.set(i, "修改值");
                arr.remove(i);
            }
        };
        new Thread(r1).start();



        for(String item: arr){
            System.out.println(item);
            System.out.println(arr.size());
        }
        System.out.println(arr.size());

    }
}
